<template>
  <view v-if="!!richText" class="product-rich-text">
    <view class="title">- 商品详情 -</view>
    <rich-text class="rich-text" :nodes="decodeText"></rich-text>
  </view>
</template>

<script lang="ts">
import "./index.less";
const htmlDecodeByRegExp = (str: string) => {
  var s = "";
  if (str.length == 0) return "";
  s = str.replace(/&amp;/g, "&");
  s = s.replace(/&lt;/g, "<");
  s = s.replace(/&gt;/g, ">");
  s = s.replace(/&nbsp;/g, " ");
  s = s.replace(/&#39;/g, "'");
  s = s.replace(/&quot;/g, '"');
  return s;
};
export default {
  props: {
    richText: {
      type: String,
      default: "",
    },
  },
  computed: {
    decodeText() {
      return htmlDecodeByRegExp(this.richText);
    },
  },
};
</script>
